package test.test6_20;

import java.util.Scanner;

public class Demo3 {


    public static void main(String[] args) {
        System.out.println("请输入数组的长度");
        Scanner sc = new Scanner(System.in);
        int length = sc.nextInt();
        int[] array = new int[length];
        System.out.println("请输入定义的数组，中间用空格隔开");
        for (int i = 0; i < length; i++) {
            array[i] = sc.nextInt();
            //System.out.print(array[i]+",");
        }

        for (int i = 0; i < length; i++) {
            for (int j = i + 1; j < length; j++) {
                if (array[i] == array[j]) {
                    array[i] = 0;//若两个数的值相等即为出现了两次，
                    array[j] = 0;//将这个相等的元素赋值为0；不为0的就是只出现一次的那个数
                }
            }
        }

        for (int i = 0; i < length; i++) {
            if (array[i] != 0) {
                System.out.println("该数组中只出现一次的数字是：" + array[i]);
            }
        }
    }


}



